package edu.uwaterloo.bicyclecomputer;

import java.io.*;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.*;
import edu.uwaterloo.bicyclecomputer.modefunctions.*;

public class TestModes {

	public static Class[] getClasses() throws IOException, ClassNotFoundException {
		BufferedReader in = new BufferedReader(new FileReader("_ModesList.txt"));
		ArrayList<Class> arrList = new ArrayList<Class>();
		while (in.ready())
			arrList.add(Class.forName("edu.uwaterloo.bicyclecomputer.modefunctions." + in.readLine()));
		in.close();
		return arrList.toArray(new Class[arrList.size()]);
	}
    
	/**
	 * @param args
	 * @throws IOException 
	 * @throws ClassNotFoundException 
	 * @throws SecurityException 
	 * @throws NoSuchMethodException 
	 * @throws InvocationTargetException 
	 * @throws IllegalArgumentException 
	 * @throws IllegalAccessException 
	 * @throws NoSuchFieldException 
	 */
	public static void main(String[] args) throws ClassNotFoundException, IOException, NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchFieldException {
		Random r = new Random();
		
		Class[] classes = getClasses();
		for (int i = 0; i < 22001; i++) {
			SystemValues.rot = r.nextInt(10);

			for (int j = 0; j < classes.length; j++) {
				Method m = classes[j].getMethod("calculate");
				m.invoke(null);
			}
			
			for (int j = 0; j < classes.length; j++) {
				Method m = classes[j].getMethod("getString");
				String name = (String) classes[j].getField("name").get(null); 
				
				String result = (String) m.invoke(null);
				System.out.print(name + ":" + result + " ");
			}
			System.out.println();
					
		}

	}

}
